package com.mian.netty.demo.service;

import com.mian.annotation.RemoteService;
import com.mian.netty.demo.UserGrpc;
import com.mian.netty.demo.UserReply;
import com.mian.netty.demo.UserRequest;
import io.grpc.stub.StreamObserver;

@RemoteService
public class UserImpl extends UserGrpc.UserImplBase {


    @Override
    public void getUserInfo(UserRequest request, StreamObserver<UserReply> responseObserver) {

        UserReply userReply = UserReply.newBuilder().setNameRep(request.getName())
                .setUseridRep(request.getUserid())
                .setPriceRep(request.getPrice())
        .setMessage("获取用户信息: " + request.getName() + "——"+ request.getPrice() + "——" + request.getUserid()).build();
        responseObserver.onNext(userReply);
        responseObserver.onCompleted();
    }
}
